#include <iostream>
#include <stack>
#include <malloc.h>
#include <cstring>
using namespace std;

long long getValue(long long x,long long y,char f){
	switch(f){
		case '+' : return x + y;
		case '-' : return x - y;
		case '*' : return x * y;
		case '/' : return x / y;
	}
}
long long getResult(char* nums){
	stack<long> st;
	long long i = 0;
	int k = 0;
	long long data = 0;
	while(nums[i] != '#'){
		while(nums[i] <= '9' && nums[i] >= '0'){
			data = data * 10 + (nums[i] - '0');
			i++;
			k = 1;
		}
		if(k == 1){
			st.push(data);
			data = 0;
			k = 0;
		}
		if(nums[i] == '+' || nums[i] == '-' || nums[i] == '/' || nums[i] == '*'){
			long long y = st.top();
			st.pop();
			long long x = st.top();
			st.pop();
			long long ans = getValue(x,y,nums[i]);
			st.push(ans);
		}
		i++;
	}
	return st.top();
}
int main(){
	char* nums = (char*)malloc(1000000*sizeof(char));
	cin.getline(nums,1000000);
	nums[strlen(nums)] = '#';
	long long res = getResult(nums);
	cout<<res % 1000000007;
	return 0;
}

